home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / MYMUD21.ZIP / MMUD21.ZIP / SOURCE / SOURCE.ZIP / META_DO.PAS < prev    next >
Pascal/Delphi Source File  |  1995-01-21  |  32KB  |  1,123 lines

  1. {$I COPYRGHT.INC}
  2.  
  3. (*---------------------------------------------------------------------------*
  4.   This unit contains all meta commands used in the game. (The commands which
  5.   start with an @.
  6.  *---------------------------------------------------------------------------*)
  7.  
  8. Unit Meta_Do;
  9. Interface
  10. Uses MyIO,     { For the READKEY in the Meta_Make_Text procedure! }
  11. {|}  Dos,
  12.      Misc,
  13.      Header,
  14.      LowLevel,
  15.      Multi,
  16.      BIN_DB;
  17.  
  18. (*---------------------------------------------------------------------------*
  19.   Set a new lock on an object. Use 'ME' to lock yourself.
  20. *---------------------------------------------------------------------------*)
  21. Procedure Meta_Set_Lock(Current : ContextType;InpStr : String);
  22. Procedure Meta_UnLock(Current : ContextType;InpStr : String);
  23.  
  24. (*---------------------------------------------------------------------------*
  25.   Accept a text of max. 1023 characters and store it. Which can be:
  26.  
  27.     0 - DESC
  28.     1 - FAIL       3 - OFAIL
  29.     2 - SUCCESS    4 - OSUCCESS
  30.     5 - MACRO
  31.     6 - FINGER
  32.  *---------------------------------------------------------------------------*)
  33. Procedure Meta_Make_Text(Current : ContextType;InpStr : String;Which : Byte);
  34.  
  35. (*---------------------------------------------------------------------------*
  36.   Meta_ChangePassword Changes the user's password. InpStr should be of the
  37.                     form <oldpassword>=<newpassword>
  38.  *---------------------------------------------------------------------------*)
  39. Procedure Meta_ChangePassword(Current : ContextType;InpStr : String);
  40.  
  41. (*---------------------------------------------------------------------------*
  42.   Meta_SetFlag Sets or resets a flag.
  43.  *---------------------------------------------------------------------------*)
  44. Procedure Meta_SetFlag(Current : ContextType;InpStr : String);
  45.  
  46. (*---------------------------------------------------------------------------*
  47.   Meta_CreateObj, creates a new THING object
  48.   Meta_HomeHere  sets the object its home to the current location.
  49.   Meta_ChangeHome changes the homelocation for playes, drones and things.
  50.  *---------------------------------------------------------------------------*)
  51. Procedure META_CreateObj(Current : ContextType;InpStr : String);
  52. Procedure META_HomeHere(Current : ContextType;InpStr : String);
  53. Procedure Meta_ChangeHome(Current : ContextType;InpStr : String);
  54.  
  55. (*---------------------------------------------------------------------------*
  56.    Meta_ChangeName changes the name of an object.
  57.  *---------------------------------------------------------------------------*)
  58. Procedure Meta_ChangeName(Current : ContextType;InpStr : String);
  59.  
  60. (*---------------------------------------------------------------------------*
  61.   Increase the level of a player with a status lower than your own.
  62.  *---------------------------------------------------------------------------*)
  63. Procedure Meta_Change_Level(Current : ContextType;InpStr : String;Diff : Integer);
  64.  
  65. (*---------------------------------------------------------------------------*
  66.   Change the ownership of an object
  67.  *---------------------------------------------------------------------------*)
  68. Procedure Meta_ChOwn(Current : ContextType; InpStr : String);
  69.  
  70. (*---------------------------------------------------------------------------*
  71.   Meta_Dig       Basic digging command
  72.   Meta_OpenLink  Creates a new link
  73.  *---------------------------------------------------------------------------*)
  74. Procedure META_Dig(Current : ContextType;InpStr : String);
  75. Procedure Meta_OpenLink(Current : ContextType;InpStr : String);
  76. Procedure Meta_Action(Current : ContextType;InpStr : String);
  77.  
  78. (*---------------------------------------------------------------------------*
  79.   Find all object owner by a user.
  80.  *---------------------------------------------------------------------------*)
  81. Procedure Meta_Find(Current : ContextType;InpStr : String);
  82.  
  83. (*---------------------------------------------------------------------------*
  84.   Teleport to a place, player or object
  85.  *---------------------------------------------------------------------------*)
  86. Procedure Meta_Teleport(Current : ContextType;InpStr : String);
  87.  
  88. (*---------------------------------------------------------------------------*
  89.   See the inforecord of an other player.
  90.  *---------------------------------------------------------------------------*)
  91. Procedure Meta_Finger(Current : ContextType;InpStr : String);
  92.  
  93. (*---------------------------------------------------------------------------*
  94.   Destroy an object and connect it to the garbage chain.
  95.  *---------------------------------------------------------------------------*)
  96. Procedure Meta_Destroy(Current : ContextType;InpStr : String);
  97.  
  98. (*---------------------------------------------------------------------------*
  99.   Edit an external file.
  100.  *---------------------------------------------------------------------------*)
  101. Procedure Meta_Edit(Current : ContextType;InpStr : String);
  102.  
  103.  
  104.  
  105. Implementation
  106. Uses Norm_do;
  107.  
  108.  
  109. (*--------------------------------------------------------------------------*)
  110. Procedure Meta_ChangePassword(Current : ContextType;InpStr : String);
  111. Var NewPass : PassString;
  112. Begin
  113. InpStr:=UpStr(InpStr);
  114.  
  115. If Not SplitCommand(InpStr,InpStr,NewPass)
  116.    Then Begin
  117.         My_WriteLn('Use @PASSWORD <OldPassword>=<NewPassword>');
  118.         Exit;
  119.         End;
  120.  
  121. Lock('Password');
  122. Current.DB.ReadObj(Current.Player);
  123. If UpStr(InpStr)<>UpStr(Current.DB.ObjRec.Password)
  124.    Then Begin
  125.         My_WriteLn('Incorrect password.');
  126.         Unlock;
  127.         Exit;
  128.         End;
  129. Current.DB.ObjRec.Password:=NewPass;
  130. Current.DB.UpdateObj(Current.Player);
  131. Unlock;
  132.  
  133. My_WriteLn('Password successful updated');
  134. End;
  135.  
  136. (*--------------------------------------------------------------------------*)
  137.  
  138. Procedure Meta_SetFlag(Current : ContextType;InpStr : String);
  139. Var ObjNr    : Integer;
  140.     Action   : String;
  141.     Negate   : Boolean;
  142. Begin
  143. InpStr:=UpStr(inpStr);
  144. If Not SplitCommand(InpStr,InpStr,Action)
  145.    Then Begin
  146.         My_WriteLn('Syntax: @SET <Obj>=[!]<FLAG>');
  147.         Exit;
  148.         End;
  149.  
  150. ObjNr:=Str2ObjNr(Current,InpStr);
  151. If ObjNr=NOTHING
  152.    Then Begin
  153.         My_WriteLn('You don''t have that object.');
  154.         Exit;
  155.         End;
  156.  
  157. Lock('Set flags');
  158. Current.DB.ReadObj(ObjNr);
  159. If (Current.Level<Wizard_Level) And
  160.    (Not (Current.DB.IsThing or Current.DB.IsRoom))
  161.    Then Begin
  162.         My_WriteLn('You can only set flags for things and rooms.');
  163.         Unlock;
  164.         Exit;
  165.         End;
  166.  
  167. If (Not Current.DB.IsOwner(Current.Player)) And
  168.    (Current.Level<Wizard_Level)
  169.    Then Begin
  170.         My_WriteLn('You don''t own '+Current.DB.Name);
  171.         Unlock;
  172.         Exit;
  173.         End;
  174.  
  175. Negate:=Action[1]='!';
  176. If Negate
  177.    Then Delete(Action,1,1);
  178. With Current.DB.ObjRec Do
  179.  Begin
  180.  Case Upcase(Action[1]) Of
  181.    'T' : If Not Negate Then SetBit(Room_Flags,Temple_Room)
  182.                        Else ResetBit(Room_Flags,Temple_Room);
  183.  
  184.    'H' : If Not Negate Then SetBit(Room_Flags,Haven_Room)
  185.                        Else ResetBit(Room_Flags,Haven_Room);
  186.  
  187.    '$' : If Not Negate Then SetBit(Room_Flags,Shop_Room)
  188.                        Else ResetBit(Room_Flags,Shop_Room);
  189.  
  190.    'O' : If Not Negate Then SetBit(Room_Flags,Loud_Room)
  191.                        Else ResetBit(Room_Flags,Loud_Room);
  192.  
  193.  
  194.    'C' : If Not Negate Then SetBit(Attr_Flags,Chown_Ok_Flag)
  195.                        Else ResetBit(Attr_Flags,ChOwn_Ok_Flag);
  196.  
  197.    'L' : If Not Negate Then SetBit(Attr_Flags,Link_Ok_Flag)
  198.                        Else ResetBit(Attr_Flags,Link_Ok_Flag);
  199.  
  200.    'S' : If Not Negate Then SetBit(attr_Flags,Sticky_Flag)
  201.                        Else ResetBit(Attr_Flags,Sticky_Flag);
  202.  
  203.    'I' : If Not Negate Then SetBit(Attr_Flags,Invisible_Flag)
  204.                        Else ResetBit(Attr_Flags,Invisible_Flag);
  205.  
  206.    'P' : If Not Negate Then SetBit(Attr_Flags,Teleport_Ok_Flag)
  207.                        Else ResetBit(Attr_Flags,Teleport_Ok_Flag);
  208.  
  209.    'D' : If Not Negate Then ObjType:=Drone_Type
  210.                        Else ObjType:=Thing_Type;
  211.  End; {Case}
  212.  End; {With}
  213. Current.DB.UpdateObj(ObjNr);
  214. Unlock;
  215. End;
  216.  
  217.  
  218. (*--------------------------------------------------------------------------*)
  219. Procedure Meta_Set_Lock(Current : ContextType;InpStr : String);
  220. Var LockObj : String;
  221.     ObjNr   : Integer;
  222. Begin
  223. If InpStr=''
  224.    Then Exit;
  225.  
  226. InpStr:=UpStr(InpStr);
  227. If Not SplitCommand(InpStr,LockObj,InpStr)
  228.    Then Begin
  229.         My_WriteLn('The syntax is @LOCK <object>=<key>|*');
  230.         exit;
  231.         End;
  232.  
  233. ObjNr:=Str2ObjNr(Current,LockObj);
  234. If ObjNr=NOTHING
  235.    Then Begin
  236.         My_WriteLn('You don''t have the '+LockObj);
  237.         Exit;
  238.         End;
  239.  
  240. If InpStr='*'
  241.    Then InpStr:='(ME&(!ME))';
  242. TranslateExpression(Current,InpStr);
  243.  
  244. Lock('Update key');
  245. Current.DB.ReadObj(ObjNr);
  246. If (Not Current.DB.IsOwnedBy(Current.Player)) And
  247.    (Not Current.DB.LevelOk(Wizard_Level))
  248.    Then Begin
  249.         My_WriteLn('You can''t lock that object!');
  250.         Unlock;
  251.         Exit;
  252.         End;
  253.  
  254. Current.DB.ObjRec.Key:=InpStr;
  255. Current.DB.UpdateObj(ObjNr);
  256. Unlock;
  257. My_WriteLn('Lock updated');
  258. End;
  259.  
  260. (*--------------------------------------------------------------------------*)
  261. Procedure Meta_UnLock(Current : ContextType;InpStr : String);
  262. Var ObjNr   : Integer;
  263. Begin
  264. If InpStr=''
  265.    Then Begin
  266.         My_WriteLn('The syntax is @UNLOCK <object>');
  267.         exit;
  268.         End;
  269.  
  270. InpStr:=UpStr(InpStr);
  271. If InpStr='ME'
  272.    Then ObjNr:=Current.Player
  273.    Else Begin
  274.         Current.DB.ReadObj(Current.Player);
  275.         ObjNr:=Str2ObjNr(Current,InpStr);
  276.         If ObjNr=NOTHING
  277.            Then Begin
  278.                 My_WriteLn('You don''t have the '+InpStr);
  279.                 Exit;
  280.                 End;
  281.         End;
  282.  
  283. Lock('Update key');
  284. Current.DB.ReadObj(ObjNr);
  285. If (Not Current.DB.IsOwnedBy(Current.Player)) And
  286.    (Not Current.DB.LevelOk(Wizard_Level))
  287.    Then Begin
  288.         My_WriteLn('You can''t unlock that object!');
  289.         Unlock;
  290.         Exit;
  291.         End;
  292.  
  293. Current.DB.ObjRec.Key:='';
  294. Current.DB.UpdateObj(ObjNr);
  295. Unlock;
  296. My_WriteLn('Object unlocked.');
  297. End;
  298.  
  299. (*--------------------------------------------------------------------------*)
  300. Procedure Meta_Make_Text(Current : ContextType;InpStr : String;Which : Byte);
  301. Var TxtRec : TextRecord;
  302.     BufPtr : Word;
  303.     LRec   : LongRec;
  304.     Stop   : Boolean;
  305.     Key    : Char;
  306.     RW     : Word;
  307.     ObjNr  : Integer;
  308.     Tmp    : File;
  309.  
  310. Begin
  311. If InpStr=''
  312.    Then exit;
  313.  
  314. If Which = 6
  315.    Then ObjNr:=Current.Db.FindPlayer(InpStr)
  316.    Else ObjNr:=NOTHING;
  317.  
  318. If ObjNr=NOTHING
  319.    Then ObjNr:=Str2ObjNr(Current,InpStr);
  320.  
  321. If ObjNr=NOTHING
  322.    Then Begin
  323.         My_WriteLn('You can''t describe that!');
  324.         Exit;
  325.         End;
  326.  
  327. Current.DB.ReadObj(ObjNr);
  328.  
  329. If (Which=6) And
  330.    (Current.Level<Wizard_Level) And
  331.    (Current.Player<>ObjNr)
  332.    Then Begin
  333.         My_WriteLn('You can only give users an information record.');
  334.         Exit;
  335.         End;
  336.  
  337.  
  338. If (Not Current.DB.IsOwnedBy(Current.Player)) And
  339.    (Current.Level<Wizard_Level)
  340.    Then Begin
  341.         My_WriteLn('You can''t do anything with that object');
  342.         Exit;
  343.         End;
  344.  
  345. Case Which Of
  346.  0 : LRec:=Current.DB.ObjRec.Desc;
  347.  1 : LRec:=Current.DB.ObjRec.Fail;
  348.  2 : LRec:=Current.DB.ObjRec.Success;
  349.  3 : LRec:=Current.DB.ObjRec.OFail;
  350.  4 : LRec:=Current.DB.ObjRec.OSuccess;
  351.  5 : LRec:=Current.DB.ObjRec.Macro;
  352.  6 : LRec:=Current.DB.ObjRec.Finger;
  353. End; {Case}
  354.  
  355. If (Editor<>'')
  356.     Then Begin
  357.          Assign(Tmp,TempDir+'DESC.'+Nr2Str(MyNode));
  358.          Rewrite(Tmp,1);
  359.          If LRec.Length>0
  360.             Then Begin
  361.                  Seek(Current.DB.TxtFile,LRec.Start);
  362.                  BlockRead(Current.DB.TxtFile,TxtRec[0],MaxLen(LRec.Length),RW);
  363.                  BlockWrite(Tmp,TxtRec[0],MaxLen(LRec.Length),RW);
  364.                  End;
  365.          Close(Tmp);
  366.          SwapVectors;
  367.          Exec(Editor,TempDir+'DESC.'+Nr2Str(MyNode));
  368.          SwapVectors;
  369.          If (DosError<>0) Or
  370.             (DosExitCode<>0)
  371.             Then Begin
  372.                  My_WriteLn('Sorry.. can''t spawn editor..');
  373.                  My_WriteLn('Please contact god or wizards.');
  374.                  My_WriteLn('Just try again for the buildin editor');
  375.                  Editor:='';
  376.                  Exit;
  377.                  End;
  378.          Reset(Tmp,1);
  379.          If FileSize(Tmp)=0
  380.             Then Begin
  381.                  Close(Tmp);
  382.                  Erase(tmp);
  383.                  Exit;
  384.                 End;
  385.          BlockRead(Tmp,TxtRec,SizeOf(TxtRec),BufPtr);
  386.          Close(Tmp);
  387.          Erase(Tmp);
  388.          End
  389.  
  390.    Else Begin
  391.         My_WriteLn('Start typing. Maximal 1023 characters. Finish with <<');
  392.         FillChar(TxtRec,SizeOf(TxtRec),#00);
  393.         BufPtr:=0;
  394.         While Not Stop Do
  395.          Begin
  396.          Key:=My_ReadKey;
  397.          Case Key Of
  398.           #8 : Begin
  399.                If BufPtr>0
  400.                   Then Begin
  401.                        My_Write(#8' '#8);
  402.                        Dec(BufPtr);
  403.                        End;
  404.                End;
  405.           #9  : ;
  406.           #13 : ;
  407.           #10 : ;
  408.           Else Begin
  409.                Stop:=(Upcase(Key)='<') and (BufPtr>0) And (TxtRec[BufPtr-1]='<');
  410.                If Not Stop
  411.                   Then Begin
  412.                        If BufPtr>1022
  413.                           Then My_Write(#7)
  414.                           Else Begin
  415.                                My_Write(Key);
  416.                                TxtRec[BufPtr]:=Key;
  417.                                Inc(BufPtr);
  418.                                End;
  419.                        End
  420.                   Else Begin
  421.                        Dec(BufPtr);
  422.                        TxtRec[BufPtr]:=#00;
  423.                        My_WriteLn('');
  424.                        End;
  425.                End;
  426.           End; {Case}
  427.           End; {While}
  428.           End;
  429.  
  430. LRec.Length:=BufPtr;
  431. Seek(Current.DB.TxtFile,FileSize(Current.DB.TxtFile));
  432. LRec.Start:=FilePos(Current.DB.TxtFile);
  433. LRec.Length:=MaxLen(BufPtr);
  434.  
  435. Lock('Updating description');
  436. Current.DB.ReadObj(ObjNr);
  437. BlockWrite(Current.DB.TxtFile,TxtRec[0],BufPtr,RW);
  438. If RW<>BufPtr
  439.    Then Begin
  440.         My_WriteLn('!! Description not saved!');
  441.         Unlock;
  442.         Exit;
  443.         End;
  444.  
  445. Case Which Of
  446.  0 : Current.DB.ObjRec.Desc:=LRec;
  447.  1 : Current.DB.ObjRec.Fail:=LRec;
  448.  2 : Current.DB.ObjRec.Success:=LRec;
  449.  3 : Current.DB.ObjRec.OFail:=LRec;
  450.  4 : Current.DB.ObjRec.OSuccess:=LRec;
  451.  5 : Current.DB.ObjRec.Macro:=LRec;
  452.  6 : Current.DB.ObjRec.Finger:=LRec;
  453. End; {Case}
  454.  
  455. Current.DB.UpdateObj(ObjNr);
  456. Unlock;
  457. End;
  458.  
  459. (*--------------------------------------------------------------------------*)
  460. Procedure META_CreateObj(Current : ContextType;InpStr : String);
  461. Var Price : Integer;
  462.     Name  : String;
  463.     ObjNr : Integer;
  464. Begin
  465. If SplitCommand(InpStr,Name,InpStr)
  466.    Then Begin
  467.         Price:=Str2Nr(InpStr);
  468.         If Price=0
  469.            Then Begin
  470.                 My_WriteLn('Creation error: incorrect price');
  471.                 Exit;
  472.                 End;
  473.         End
  474.    Else Begin
  475.         Price:=10;
  476.         Name:=InpStr;
  477.         End;
  478.  
  479. If CleanUp(Name)=''
  480.    Then Begin
  481.         My_WriteLn('You have to give the thing a name.');
  482.         Exit;
  483.         End;
  484.  
  485. ObjNr:=Str2ObjNr(Current,Name);
  486. If ObjNr<>NOTHING
  487.    Then Begin
  488.         My_WriteLn('You already have a '+Name);
  489.         Exit;
  490.         End;
  491.  
  492.  
  493. Current.DB.ReadObj(Current.Player);
  494. If (Not Current.DB.LevelOk(Wizard_Level)) And
  495.    (Current.DB.ObjRec.Pennies<Price)
  496.    Then Begin
  497.         My_WriteLn('Sorry, you can''t affort this creation.');
  498.         Exit;
  499.         End;
  500.  
  501. ObjNr:=CreateNewObject(Current,Thing_Type,Name,Price);
  502. My_WriteLn('Out of a puff of smoke you created a '+name+' (#'+Nr2Str(ObjNr)+')');
  503. End;
  504.  
  505.  
  506.  
  507.  
  508.  
  509. (*--------------------------------------------------------------------------*)
  510. Procedure META_HomeHere(Current : ContextType;InpStr : String);
  511. Var ObjNr  : Integer;
  512. Begin
  513. If InpStr=''
  514.    Then exit;
  515.  
  516. Current.DB.ReadObj(Current.Room);
  517. If Not (Current.DB.IsOwner(Current.Player) or
  518.        Current.DB.LevelOk(Wizard_Level))
  519.    Then Begin
  520.         My_WriteLn('You don''t own this location.');
  521.         Exit;
  522.         End;
  523.  
  524. ObjNr:=Str2ObjNr(Current,InpStr);
  525. If (ObjNr=NOTHING)
  526.    Then Begin
  527.         My_WriteLn('You can''t have that.');
  528.         Exit;
  529.         End;
  530.  
  531. Lock('Home Object');
  532. Current.DB.ReadObj(ObjNr);
  533. If Not (Current.DB.IsOwner(Current.Player) Or
  534.         (Current.Level>=Wizard_Level))
  535.    Then Begin
  536.         My_WriteLn('You don''t own '+Current.DB.Name);
  537.         Unlock;
  538.         Exit;
  539.         End;
  540. Current.DB.ObjRec.Exits:=Current.Room;
  541. Current.DB.UpdateObj(ObjNr);
  542. Unlock;
  543. End;
  544.  
  545.  
  546. (*--------------------------------------------------------------------------*)
  547. Procedure Meta_ChangeName(Current : ContextType;InpStr : String);
  548. Var ObjNr   : Integer;
  549.     OldName : String;
  550. Begin
  551. If InpStr=''
  552.    Then exit;
  553. InpStr:=CleanUp(InpStr);
  554. If Not SplitCommand(InpStr,OldName,InpStr)
  555.    Then Begin
  556.         My_WriteLn('Syntax: @NAME <OldName>=<NewName>');
  557.         Exit;
  558.         End;
  559.  
  560. ObjNr:=Str2ObjNr(Current,OldName);
  561. If ObjNr=NOTHING
  562.    Then Begin
  563.         If Can_Move(Current,OldName)
  564.            Then ObjNr:=ExitNr
  565.            Else Begin
  566.                 My_WriteLn('You can''t do that!');
  567.                 Exit;
  568.                 End;
  569.         End;
  570.  
  571. Lock('Update name');
  572. Current.DB.ReadObj(ObjNr);
  573. If Not (Current.DB.IsOwner(Current.Player) or
  574.        (Current.Level>=Wizard_Level))
  575.    Then Begin
  576.         My_WriteLn('You don''t own that object!');
  577.         Unlock;
  578.         Exit;
  579.         End;
  580. Current.DB.ObjRec.Name:=inpStr;
  581. Current.DB.UpdateObj(ObjNr);
  582. Unlock;
  583. End;
  584.  
  585. (*--------------------------------------------------------------------------*)
  586. Procedure Meta_ChangeHome(Current : ContextType;InpStr : String);
  587. Var ObjNr   : Integer;
  588.     OldName : String;
  589.     Location: Integer;
  590. Begin
  591. If InpStr=''
  592.    Then exit;
  593.  
  594. InpStr:=CleanUp(InpStr);
  595. If Pos('=',InpStr)=0
  596.    Then InpStr:=InpStr+'=HERE';
  597.  
  598. If Not SplitCommand(InpStr,OldName,InpStr)
  599.    Then Begin
  600.         My_WriteLn('Syntax: @HOME <Name>[=<Location>]');
  601.         Exit;
  602.         End;
  603.  
  604. ObjNr:=Str2ObjNr(Current,OldName);
  605. If ObjNr=NOTHING
  606.    Then Begin
  607.         My_WriteLn(OldName+' is not here.');
  608.         Exit;
  609.         End;
  610.  
  611. Current.DB.ReadObj(ObjNr);
  612. If Current.DB.IsRoom or Current.DB.IsExit
  613.    Then Begin
  614.         My_WriteLn('You cannot change the HOME of exits or rooms.');
  615.         Exit;
  616.         End;
  617.  
  618. Location:=Str2Objnr(Current,InpStr);
  619. If Location=NOTHING
  620.    Then Begin
  621.         My_WriteLn(InpStr+' doesn''t exist.');
  622.         Exit;
  623.         End;
  624.  
  625. Lock('Update name');
  626. Current.DB.ReadObj(ObjNr);
  627. If Not (Current.DB.IsOwner(Current.Player) or
  628.        (Current.Level>=Wizard_Level))
  629.    Then Begin
  630.         My_WriteLn('You don''t own that object!');
  631.         Unlock;
  632.         Exit;
  633.         End;
  634. Current.DB.ObjRec.Exits:=Location;
  635. Current.DB.UpdateObj(ObjNr);
  636. Unlock;
  637. End;
  638.  
  639.  
  640. (*--------------------------------------------------------------------------*)
  641.  
  642.  
  643.  
  644. Procedure Meta_Change_Level(Current : ContextType;InpStr : String;Diff : Integer);
  645. Var ObjNr : Integer;
  646. Begin
  647. If InpStr=''
  648.    Then Exit;
  649. ObjNr:=Str2ObjNr(Current,InpStr);
  650. If ObjNr=NOTHING
  651.    Then begin
  652.         My_WriteLn('That user doesn''t exist.');
  653.         Exit;
  654.         End;
  655.  
  656. Lock('Raise level');
  657. Current.DB.ReadObj(ObjNr);
  658. If Not Current.DB.IsPlayer
  659.    Then Begin
  660.         My_WriteLn(Current.DB.Name+' is not a player.');
  661.         Unlock;
  662.         Exit;
  663.         End;
  664.  
  665. If ObjNr=Current.Player
  666.    Then Begin
  667.         My_WriteLn('Joker!');
  668.         Unlock;
  669.         Exit;
  670.         End;
  671.  
  672. {$IfNDef MakeGod}
  673. If ((Current.DB.ObjRec.ObjLevel+Diff)>=Current.Level) or
  674.    ((Current.DB.ObjRec.ObjLevel+Diff)<0)
  675.    Then Begin
  676.         My_WriteLn('You can''t promote people to a level higher or equal than your own.');
  677.         Unlock;
  678.         Exit;
  679.         End;
  680. {$EndIf}
  681. Inc(Current.DB.ObjRec.ObjLevel,Diff);
  682. Current.DB.UpdateObj(ObjNr);
  683. Unlock;
  684.  
  685. My_WriteLn('Level successful changed to '+LevelNames[Current.DB.ObjRec.ObjLevel]);
  686. SayPrivate(ObjNr,'+You are now a '++LevelNames[Current.DB.ObjRec.ObjLevel]+'.');
  687. End;
  688.  
  689.  
  690. (*--------------------------------------------------------------------------*)
  691. Procedure Meta_ChOwn(Current : ContextType; InpStr : String);
  692. Var ObjNr    : Integer;
  693.     Name     : String;
  694.     Player   : Integer;
  695.     PlayerOk : Boolean;
  696. Begin
  697. If InpStr=''
  698.    Then Exit;
  699.  
  700. InpStr:=UpStr(InpStr);
  701.  
  702.  
  703. If Not SplitCommand(InpStr,InpStr,Name)
  704.    Then Begin
  705.         My_WriteLn('Who should own what?');
  706.         Exit;
  707.         End;
  708.  
  709. ObjNr:=Str2ObjNr(Current,InpStr);
  710. If ObjNr=NOTHING
  711.    Then Begin
  712.         My_WriteLn('That object isn''t here.');
  713.         Exit;
  714.         End;
  715.  
  716. Player:=Current.DB.FindPlayer(Name);
  717. If Player=NOTHING
  718.    Then Begin
  719.         My_WriteLn('There is no player with that name.');
  720.         Exit;
  721.         End;
  722.  
  723. Current.DB.ReadObj(Player);
  724. PlayerOk:=Current.DB.IsChownOk or Current.DB.LevelOk(Wizard_Level);
  725.  
  726. If Not PlayerOk
  727.    Then Begin
  728.         My_WriteLn(Current.DB.Name+' doesn''t accept ownership of strange objects.');
  729.         Exit;
  730.         End;
  731.  
  732. Lock('Changing owner');
  733. Current.DB.ReadObj(ObjNr);
  734. If Not (Current.DB.IsOwner(Current.Player) Or
  735.        (Current.Level>=Wizard_Level))
  736.    Then Begin
  737.         My_WriteLn('You don''t own that object.');
  738.         Unlock;
  739.         Exit;
  740.         End;
  741.  
  742. Current.DB.ObjRec.Owner:=Player;
  743. Current.DB.UpdateObj(ObjNr);
  744. Unlock;
  745. My_WriteLn('The ownership has changed.');
  746. End;
  747.  
  748. (*--------------------------------------------------------------------------*)
  749. Procedure Meta_CreateLink(Current : ContextType; InpStr : String);
  750. Var Dirs  : String;
  751.     Name  : String;
  752.     ObjNr : Integer;
  753. Begin
  754. Current.DB.ReadObj(Current.Player);
  755. If (Not Current.DB.LevelOk(Wizard_Level)) And
  756.    (Current.DB.ObjRec.Pennies<10)
  757.    Then Begin
  758.         My_WriteLn('Sorry, you can''t affort a new room.');
  759.         Exit;
  760.         End;
  761.  
  762. ObjNr:=CreateNewObject(Current,Room_Type,Name,2);
  763. My_WriteLn('With crashing rock you create a room called '+Name+' (#'+Nr2Str(Objnr)+')');
  764.  
  765. End;
  766.  
  767. (*--------------------------------------------------------------------------*)
  768. Procedure DropLink( Current      : ContextType;
  769.                     LinkNr,ObjNr : Integer;
  770.                     Flags        : LongInt);
  771. Var RecNr : Integer;
  772. Begin
  773. Lock('New link');
  774. Current.DB.ReadObj(Current.Room);
  775. If Current.DB.ObjRec.Exits=NOTHING
  776.    Then Begin
  777.         RecNr:=Current.Room;
  778.         Current.DB.ObjRec.Exits:=LinkNr;
  779.         End
  780.    Else Begin
  781.         RecNr:=Current.DB.ObjRec.Exits;
  782.         Current.DB.ReadObj(RecNr);
  783.         While Current.DB.ObjRec.Next<>NOTHING Do
  784.          Begin
  785.          RecNr:=Current.DB.ObjRec.Next;
  786.          Current.DB.ReadObj(RecNr);
  787.          End;
  788.         Current.DB.ObjRec.Next:=LinkNr;
  789.         End;
  790.  
  791. Current.DB.UpdateObj(RecNr);
  792. Current.DB.ReadObj(LinkNr);
  793. Current.DB.ObjRec.Location:=ObjNr;
  794. Current.DB.ObjRec.Next:=NOTHING;
  795. Current.DB.ObjRec.GenFlags:=Current.DB.ObjRec.GenFlags Or Flags;
  796. Current.DB.UpdateObj(LinkNr);
  797. Unlock;
  798. End;
  799.  
  800.  
  801. Procedure META_Dig(Current : ContextType;InpStr : String);
  802. Var Dirs  : String;
  803.     Name  : String;
  804.     ObjNr : Integer;
  805.     LinkNr: Integer;
  806. Begin
  807. If Not SplitCommand(InpStr,Name,Dirs)
  808.    Then Begin
  809.         Name:=InpStr;
  810.         Dirs:='';
  811.         {My_WriteLn('Syntax: @DIG <Name>=<Direction>');
  812.         Exit;}
  813.         End;
  814.  
  815. If CleanUp(Name)=''
  816.    Then Begin
  817.         My_WriteLn('You have to give the room a name.');
  818.         Exit;
  819.         End;
  820.  
  821. If Str2ObjNr(Current,Name)<>NOTHING
  822.    Then Begin
  823.         My_WriteLn('There is already an object with that name here.');
  824.         Exit;
  825.         End;
  826.  
  827. If Str2ObjNr(Current,Dirs)<>NOTHING
  828.    Then Begin
  829.         My_WriteLn('That exit is already in use.');
  830.         Exit;
  831.         End;
  832.  
  833. Current.DB.ReadObj(Current.Room);
  834. If Not (Current.DB.IsLinkOk Or Current.DB.IsOwner(Current.Player))
  835.    Then Begin
  836.         My_WriteLn('You are not allowed to dig here..');
  837.         Exit;
  838.         End;
  839.  
  840. Current.DB.ReadObj(Current.Player);
  841. If (Not Current.DB.LevelOk(Wizard_Level)) And
  842.    (Current.DB.ObjRec.Pennies<10)
  843.    Then Begin
  844.         My_WriteLn('Sorry, you can''t affort a new room.');
  845.         Exit;
  846.         End;
  847.  
  848. ObjNr:=CreateNewObject(Current,Room_Type,Name,2);
  849. My_WriteLn('With crashing rock you create a room called '+Name+' (#'+Nr2Str(Objnr)+')');
  850.  
  851. If Dirs<>''
  852.    Then Begin
  853.         My_WriteLn('Let''s see if we can link..');
  854.         LinkNr:=CreateNewObject(Current,Exit_Type,Dirs,2);
  855.         DropLink(Current,LinkNr,ObjNr,0);
  856.         My_WriteLn('Linked ok.');
  857.         Current.DB.ResetAll;
  858.         End
  859.    Else MoveTo(ObjNr,Current.Player);
  860.  
  861. End;
  862.  
  863. (*--------------------------------------------------------------------------*)
  864. Procedure Meta_OpenLink(Current : ContextType;InpStr : String);
  865. Var Name   : String;
  866.     ObjNr  : Integer;
  867.     LinkNr : Integer;
  868. Begin
  869. If InpStr=''
  870.    Then Exit;
  871. If Not SplitCommand(InpStr,Name,InpStr)
  872.    Then Begin
  873.         My_WriteLn('Syntax: @OPEN <Direction>[;<Direction>]=#<TargetRoomNr.>');
  874.         Exit;
  875.         End;
  876.  
  877. If Str2ObjNr(Current,Name)<>NOTHING
  878.    Then Begin
  879.         My_WriteLn('There is already an object with that name here.');
  880.         Exit;
  881.         End;
  882.  
  883.  
  884. ObjNr:=Str2ObjNr(Current,InpStr);
  885. If ObjNr=NOTHING
  886.    Then Begin
  887.         My_WriteLn('Couldn''t find the target room');
  888.         Exit;
  889.         End;
  890.  
  891. Current.DB.ReadObj(ObjNr);
  892. If (Not Current.DB.IsLinkOk) And
  893.    (Current.DB.ObjRec.Owner<>Current.Player)
  894.    Then Begin
  895.         My_WriteLn('You don''t own the target room.');
  896.         Exit;
  897.         End;
  898.  
  899. LinkNr:=CreateNewObject(Current,Exit_Type,Name,2);
  900. DropLink(Current,LinkNr,ObjNr,0);
  901. My_WriteLn('Linked.');
  902. End;
  903.  
  904. (*--------------------------------------------------------------------------*)
  905. Procedure Meta_Action(Current : ContextType;InpStr : String);
  906. Var LinkNr : Integer;
  907. Begin
  908. If InpStr=''
  909.    Then Exit;
  910.  
  911. If Str2ObjNr(Current,InpStr)<>NOTHING
  912.    Then Begin
  913.         My_WriteLn('There is already an object with that name here.');
  914.         Exit;
  915.         End;
  916.  
  917. Current.DB.ReadObj(Current.Room);
  918. If Not (Current.DB.IsLinkOk and Current.DB.IsOwner(Current.Player))
  919.    Then Begin
  920.         My_WriteLn('You can''t link here..');
  921.         Exit;
  922.         End;
  923.  
  924. LinkNr:=CreateNewObject(Current,Exit_Type,InpStr,2);
  925. DropLink(Current,LinkNr,Current.Room,0);
  926. My_WriteLn('Action created');
  927. End;
  928.  
  929. (*--------------------------------------------------------------------------*)
  930. Procedure Meta_Find(Current : ContextType;InpStr : String);
  931. Var ObjNr : Integer;
  932.     Count : Integer;
  933. Begin
  934. If InpStr=''
  935.    Then ObjNr:=Current.Player
  936.    Else Begin
  937.         If Current.Level>=Wizard_Level
  938.            Then ObjNr:=Current.DB.FindPlayer(InpStr)
  939.            Else Begin
  940.                 My_WriteLn('Huh?');
  941.                 Exit;
  942.                 End;
  943.         End;
  944.  
  945. Lock('Pay for @FIND');
  946. Current.DB.ReadObj(Current.Player);
  947. If Current.DB.ObjRec.Pennies=0
  948.    Then Begin
  949.         My_WriteLn('Sorry, you can''t afford a @FIND.');
  950.         Unlock;
  951.         Exit;
  952.         End;
  953. Dec(Current.DB.ObjRec.Pennies);
  954. Current.DB.UpdateObj(Current.Player);
  955. Unlock;
  956.  
  957. My_WriteLn('Obj# Loc  Name');
  958. My_WriteLn('---- ---- -------------------------------------------------------');
  959. Seek(Current.DB.ObjFile,0);
  960. Count:=0;
  961. While Not Eof(Current.DB.ObjFile) Do
  962.  Begin
  963.  Current.DB.ReadObj(Count);
  964.  If Current.DB.IsOwner(ObjNr)
  965.     Then My_WriteLn(Nr2FStr(Count,4)+' '+Nr2FStr(Current.DB.ObjRec.Location,4)+' '+Current.DB.Name);
  966.  Inc(Count);
  967.  End;
  968. My_WriteLn('');
  969. End;
  970.  
  971. (*--------------------------------------------------------------------------*)
  972. Procedure Meta_Teleport(Current : ContextType;InpStr : String);
  973. Var ObjNr   : Integer;
  974.     OldRoom : Integer;
  975. Begin
  976. OldRoom:=Current.Room;
  977. If InpStr=''
  978.    Then Begin
  979.         My_WriteLn('Syntax: @teleport <Username>');
  980.         Exit;
  981.         End;
  982.  
  983. ObjNr:=Current.DB.FindPlayer(InpStr);
  984. If (ObjNr=NOTHING)
  985.    Then Begin
  986.         ObjNr:=Str2ObjNr(Current,InpStr);
  987.         If ObjNr=NOTHING
  988.            Then Exit;
  989.         End;
  990.  
  991. Current.DB.ReadObj(ObjNr);
  992. If Not Current.DB.IsRoom
  993.    Then Begin
  994.         ObjNr:=Current.DB.ObjRec.Location;
  995.         Current.DB.ReadObj(ObjNr);
  996.         End;
  997.  
  998. If Not (Current.DB.IsRoom and Current.DB.CanTeleport)
  999.    Then Begin
  1000.         My_WriteLn('Sorry, you can''t teleport there.');
  1001.         Exit;
  1002.         End;
  1003.  
  1004. Current.Room:=ObjNr;
  1005. MoveTo(Current.Player,Current.Room);
  1006. HandleDrones(0,Current,OldRoom);
  1007. End;
  1008.  
  1009. (*--------------------------------------------------------------------------*)
  1010. Procedure Meta_Finger(Current : ContextType;InpStr : String);
  1011. Var ObjNr   : Integer;
  1012. Begin
  1013. If InpStr=''
  1014.    Then Begin
  1015.         My_WriteLn('@Finger <ObjectName>');
  1016.         Exit;
  1017.         End;
  1018.  
  1019. ObjNr:=Current.DB.FindPlayer(InpStr);
  1020. If ObjNr=NOTHING
  1021.    Then ObjNr:=Str2ObjNr(Current,InpStr);
  1022.  
  1023. If ObjNr=NOTHING
  1024.    Then Begin
  1025.         My_WriteLn('Player unknown');
  1026.         Exit;
  1027.         End;
  1028.  
  1029. Current.DB.ReadObj(ObjNr);
  1030. Current.DB.Finger('User has no INFO description set.');
  1031. End;
  1032.  
  1033.  
  1034.  
  1035. Procedure Meta_Destroy(Current : ContextType;InpStr : String);
  1036. Var ObjNr   : Integer;
  1037. Begin
  1038. If InpStr=''
  1039.    Then Begin
  1040.         My_WriteLn('Syntax: @DESTROY <Name>');
  1041.         Exit;
  1042.         End;
  1043.  
  1044. ObjNr:=Str2ObjNr(Current,InpStr);
  1045. If ObjNr=NOTHING
  1046.    Then Begin
  1047.         My_WriteLn('You don''t have that object.');
  1048.         Exit;
  1049.         End;
  1050.  
  1051. Current.DB.ReadObj(ObjNr);
  1052. If (Not Current.DB.IsOwner(ObjNr)) And
  1053.    (Current.Level<Wizard_Level)
  1054.    Then Begin
  1055.         My_WriteLn('You don''t own the object.');
  1056.         Exit;
  1057.         End;
  1058.  
  1059. If Not Current.DB.IsThing
  1060.    Then Begin
  1061.         My_WriteLn('You can only destroy things.');
  1062.         Exit;
  1063.         End;
  1064.  
  1065.  
  1066. Current.DB.ReadObj(Current.Player);
  1067. If Current.DB.ObjRec.Garbage=0
  1068.    Then Current.DB.ObjRec.Garbage:=0;
  1069. MoveTo(ObjNr,Current.DB.ObjRec.Garbage);
  1070.  
  1071. Lock('Updating garbage');
  1072. Current.DB.ReadObj(ObjNr);
  1073. With Current.DB Do
  1074.   FillChar(ObjRec,SizeOf(ObjRec),#00);
  1075.  
  1076. With Current.DB.ObjRec Do
  1077.  Begin
  1078.  Name:='Garbage #'+Nr2Str(ObjNr);
  1079.  Key:='';
  1080.  Password:='';
  1081.  Owner:=Current.Player;
  1082.  End;
  1083. Current.DB.UpdateObj(ObjNr);
  1084. Unlock;
  1085.  
  1086. End;
  1087.  
  1088. Procedure Meta_Edit(Current : ContextType;InpStr : String);
  1089. Var Tmp : File;
  1090.     S   : SearchRec;
  1091. Begin
  1092. InpStr:=ChangePathTo(InpStr,TextPath);
  1093.  
  1094. If Not ExistFile(InpStr)
  1095.    Then Begin
  1096.         If Current.Level<GOD_Level
  1097.            Then Begin
  1098.                 My_WriteLn('Textfile not found. Please contact your GOD');
  1099.                 Exit;
  1100.                 End
  1101.            Else Begin
  1102.                 Assign(Tmp,InpStr);
  1103.                 Rewrite(Tmp);
  1104.                 Close(Tmp);
  1105.                 If IoResult<>0 Then;
  1106.                 End;
  1107.         End;
  1108. SwapVectors;
  1109. Exec(Editor,InpStr);
  1110. SwapVectors;
  1111. If Current.Level=GOD_Level
  1112.    Then Begin
  1113.         FindFirst(InpStr,AnyFile,S);
  1114.         If S.Size<=2
  1115.            Then Begin
  1116.                 Erase(Tmp);
  1117.                 If IoResult<>0 Then;
  1118.                 End;
  1119.         End;
  1120. End;
  1121.  
  1122. End.
  1123.